{include file=header.html}
<script language="javascript" type="text/javascript" src="{res file=DatePicker/WdatePicker.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
<script language="javascript" type="text/javascript">
$(function() {
	$('th[type="order"]').click(function() {
		var order = $(this).attr('field') + '-' + $(this).attr('order');
		$('#order').val(order);
		$('input[name="search"]').click();
	}).css({'cursor': 'pointer', 'color': '#36c'});
	var order = $('#order').val().split('-');
	var field = $('th[type="order"][field="' + order[0] + '"]');
	if (order[1] == 'ASC') {
		field.attr('order', 'DESC').text(field.text() + '↑');
	} else {
		field.attr('order', 'ASC').text(field.text() + '↓');
	}
	if (order[0] != 'arrival_date') {
		$('th[type="order"][field="arrival_date"]').attr('order', 'DESC');
	}
	var isdblclick=0;
	$('td[type="edit"]').dblclick(function() {
		//var html = $(this).text().replace('<br>', '');
		
		if(isdblclick==0)
			 {
			   var html = $(this).html();
			 }
			 else if(isdblclick==1)
			 {
				var html = $(this).text();
			 }
			 isdblclick=1;
		var textarea = $('<textarea style="width:100%; height:50px;">' + html + '</textarea>');
		textarea.blur(function() {
			var _this = $(this);
			var data = _this.val();
			var url = 'index.php?app=sample&act=edit_desc&id=' + _this.parent().attr('sample_id');
			$.post(url, {'description': data}, function(msg) {
				if (msg == 'success') {
				    isdblclick=0;
					_this.parent().html(nl2br(data));
				} else {
					alert(msg);
				}
			});
		});
		$(this).html('').append(textarea);
		textarea.focus();
	});
	
	$("#brand_id").change(function(){
			var url="index.php?app=sample&act=ajax_get_buyer&id="+$(this).val();
			$.getJSON(url,function(ret){
					if(ret)
					{
						$("#buyer_id option").remove();
						$("#buyer_id").append('<option value="0"></option>');
						for(i in ret)
						{
							$("#buyer_id").append('<option value="'+ret[i]['user_id']+'" >'+ret[i]['user_name']+'</option>');
						}
					}
				});
		
		
		});
});
function nl2br (str) {
	var arr = str.split('\n');
	var ret = '';
	for (var i = 0; i < arr.length; i++) {
		ret += arr[i];
		if (i != arr.length - 1) {
			ret += '<br>\n';
		}
	}
	return ret;
}

function chang_tab(obj)
{
	$(".introduce_ti p").each(function(){
		$(this).attr('class','');
	});
	$("#sample_sc"+obj).attr('class','in_tis');
}
</script>
<body>
<!--收起展开 开始 -->
<!--<div class="sub-body" style="padding:20px 25px 0 25px;">
  <a href="" onClick="$('#search_box').slideToggle();return false;">收起/展开</a>
</div> -->
<!--收起展开 结束 -->
<div class="sub-body" id="search_box">
  <h3 class="title-1" style="display:none;">{$lang.evaluate_list}</h3>
  <div id="search_frame">
  <form method="get" action="">
  <input type="hidden" name="app" value="evaluate">
  <input type="hidden" name="act" value="index">
    <table width="95%" cellpadding="0" cellspacing="0" class="search" >
      <tr>
        <th width="120">到板日期：</th>
        <td width="145"><input type="text" name="arrival_date_start" class="input-6" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{$smarty.get.arrival_date_start}" />
          至
          <input type="text" name="arrival_date_end" class="input-6" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{$smarty.get.arrival_date_end}"/></td>
        <th width="120">板&nbsp;&nbsp;&nbsp; 号：</th>
        <td width="140"><input type="text" name="sample_sn" class="input-1" value="{$smarty.get.sample_sn}"/></td>
 
        <th width="120">工&nbsp;&nbsp;&nbsp; 厂：</th>
        <td width="140"><select name="factory_id" {if $user.role eq USER_FACTORY}disabled{/if}>
          <option value="0"></option>
		  <!--{foreach from=$factory_list item=factory}-->
          <option value="{$factory.factory_id}" {if $factory.factory_id == $smarty.get.factory_id}selected{/if}>{$factory.factory_name|escape}</option>
		  <!--{/foreach}-->
        </select></td>
                <td rowspan="2" width="100"><input name="search" type="submit" class="inquiry" value="{$lang.search}"/><!--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="btn-2" value="清空条件" acttype="clear">--><input type="hidden" id="order" name="order" value="{if $smarty.get.order}{$smarty.get.order}{else}arrival_date-DESC{/if}" /></td>
      </tr>
    
      <tr>
      
              <th>品&nbsp;&nbsp;&nbsp; 牌：</th>
        <td><select name="brand_id" id="brand_id">
          <option value="0"></option>
		  <!--{foreach from=$brand_list item=brand}-->
          <option value="{$brand.brand_id}" {if $brand.brand_id == $smarty.get.brand_id}selected{/if}>{$brand.brand_name|escape}&nbsp;&nbsp;({$brand.company_name|escape})</option>
		  <!--{/foreach}-->
        </select></td>
        			<th>买&nbsp;&nbsp;&nbsp; 手：</th>
        <td><select name="buyer_id" id="buyer_id">
          <option value="0"></option>
		  <!--{foreach from=$buyer_list item=buyer}-->
          <option value="{$buyer.user_id}" {if $buyer.user_id == $smarty.get.buyer_id}selected{/if}>{$buyer.user_name|escape}</option>
		  <!--{/foreach}-->
        </select></td>
        <th>跟&nbsp;&nbsp;&nbsp; 单：</th>
      	<td><select name="merch_id"{if !$user_manage && !$user_assistant} disabled{/if}>
      		<option value="0"></option>
      		<!--{foreach from=$merch_list item=merch}-->
      		<option value="{$merch.user_id}"{if $user_manage || $user_assistant}{if $merch.user_id == $smarty.get.merch_id} selected{/if}{else}{if $visitor.user_id == $merch.user_id} selected{/if}{/if}>{$merch.user_name}</option>
      		<!--{/foreach}-->
      		</select></td>	
        </tr>
    </table>
	</form>
  </div> 
  <div class="tab_info">
  <div class="tab-title-1"><span>{$lang.evaluate_list}</span></div>
    <table width="100%" cellspacing="0" cellpadding="0" class="tab-display" id="tab-color1">
      <tr>
        <th width="4%">{$lang.No}</th>
        <th width="10%" type="order" field="arrival_date" order="ASC">{$lang.arrival_date}</th>
        <th width="7%" type="order" field="sample_sn" order="ASC">{$lang.sample_sn}</th>
		<th width="7%">图片</th>
        <th width="10%" type="order" field="brand_name" order="ASC">{$lang.brand_name}</th>
        <th width="10%" type="order" field="buyer_id" order="ASC">{$lang.buyer_name}</th>
        <th width="10%" type="order" field="user_name" order="ASC">{$lang.merchandiser}</th>
        <th width="10%" type="order" field="factory_name" order="ASC">{$lang.factory_name}</th>
        <th width="10%" type="order" field="to_factory_date" order="DESC">{$lang.to_factory_date}</th>
        <th width="7%" type="order" field="sample_made_days" order="ASC">板期</th>
        <th width="7%">报价</th>
        <th>操作</th>
      </tr>
	  <!--{foreach from=$sample_list item=sample name=sm}-->
      <tr{if $sample.sourcing_days > 7 || $sample.sample_made_days > 7} {/if}>
        <td>{$smarty.foreach.sm.iteration}</td>
        <td>{$sample.arrival_date|date:Y-m-d}</td>
        <td><a style="color:blue" href="
        {url app=sample&act=show&id=$sample.sample_id}
        ">{$sample.sample_sn|escape}</a></td>
		<td><a href="{$sample.front_pic}" target="_blank"><img src="{$sample.front_pic}" width="80" style="border:none;" alt="图片" /></a></td>
        <td>{$sample.brand_name|escape}</td>
        <td>{$sample.member_name|escape}</td>
        <td>{$sample.user_name|escape}</td>
        <td>{$sample.factory_name|escape}</td>
        <td>{$sample.to_factory_date|date:Y-m-d}</td>
        <td>{$sample.sample_made_days|escape}天</td>
        <td>{$sample.factory_price|escape}</td>
        <td><a href="{url app=evaluate&act=evaluate&sample_id=$sample.sample_id}">{$lang.evaluate}</a></td>
      </tr>
	  <!--{/foreach}-->
         </table>
  		{include file=page.html}
  </div>
</div>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</body>
</html>